<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.bilyet}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            
            <h:form>
                <script type="text/javascript">
                    
                </script>
                
                <p:outputPanel autoUpdate="true">
                    <p:toolbar>
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"
                                         action="#{bilyetsimBean.newData()}" process="@this" update="displayBilyetsim" 
                                         widgetVar="btnNewLoansim" 
                                         rendered="#{ugpolicyBean.cekButtonAccess(308,'INS;')}" >
                            <pe:resetEditableValues for="displayLoansim"/>  
                        </p:commandButton>
                        
                        <p:commandButton value="#{bundle.btnSimulate}" icon="ui-icon-search"
                                         rendered="#{ugpolicyBean.cekButtonAccess(308,'INS;')}"
                                          action="#{bilyetsimBean.simulasi()}" process="@form" update="dtBilyetsim" >
                        </p:commandButton>
                        
<!--                         <p:commandButton value="#{bundle.btnSimulate}" icon="ui-icon-search"
                                         rendered="#{ugpolicyBean.cekButtonAccess(308,'INS;')}"
                                         action="#{bilyetsimBean.simulasi2()}" process="@form" update="dtBilyetsim" >
                        </p:commandButton>-->
                        
                        <p:commandButton type="push" action="#{rptBilyetsimBean.execute(bilyetsimBean.bilyets)}" value="#{bundle.btnPrint}"  
                                         ajax="false" image="ui-icon-print" rendered="#{ugpolicyBean.cekButtonAccess(308,'PRN;')}" >
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyets}" target="#{rptBilyetsimBean.sim}" />
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyet.bilyetDate}" target="#{rptBilyetsimBean.bilyetDate}" />
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyet.deproduct.productName}" target="#{rptBilyetsimBean.productName}" />
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyet.interestAmount}" target="#{rptBilyetsimBean.interest}" />
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyet.interestRate}" target="#{rptBilyetsimBean.interestRate}" />
                            <f:setPropertyActionListener value="#{bilyetsimBean.bilyet.principleAmount}" target="#{rptBilyetsimBean.principalAmount}" />
                            
                        </p:commandButton>
                        
                        
                    </p:toolbarGroup>
                    
                    <p:toolbarGroup align="right">
                        <p:commandButton id="doNothingBilyetsim" type="button" value="" style="width: 0px; height: 0px;"/> 
                         <p:defaultCommand target="doNothingBilyetsim"/> 
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>    
                    
                
                <h:panelGrid id="displayBilyetsim" styleClass="addELIT" cellpadding="0" >
                    <h:panelGrid columns="2" rowClasses="panelGridId" >
                        <p:panel header="#{bundle.bilyetLedgend}" >
                            <h:panelGrid columns="3" cellpadding="0" cellspacing="5">
                                
                                <h:outputLabel value= "#{bundle.bilyetDate}" /><h:outputLabel value= ":" />
                                <h:outputText value="#{bilyetsimBean.bilyet.bilyetDate}" />
                                
                                <h:outputLabel value="#{bundle.deproduct}" /><h:outputLabel value= ":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0" >
                                    <p:selectOneMenu value="#{bilyetsimBean.bilyet.deproduct.deproductId}" id="bilyetProdIdsim" label="#{bundle.deproduct}" 
                                            requiredMessage="#{bundle.deproduct} #{bundle.requiredInput}" 
                                            required="true" style="width: 202px;" disabled="#{!bilyetsimBean.authorized}">
                                        <f:selectItem itemLabel="" itemValue="" />
                                        <f:selectItems value="#{bilyetsimBean.avblProd}" />
                                        <p:ajax update="msgbilyetProdIdsim bilyetNumOfPeriod bilyetPeriodOpt bilyetInterestAmountsim bilyetTaxAmountsim" listener="#{bilyetsimBean.handleProdChange}" />  
                                    </p:selectOneMenu>
                                    <p:message id="msgbilyetProdIdsim" for="bilyetProdIdsim" display="icon" />
                                </h:panelGrid>
                                              
                                <h:outputLabel value= "#{bundle.period}" /><h:outputLabel value= ":" />
                                <h:outputText id="bilyetPeriodOpt" value="#{constantaBean.getDeptPeriodText(bilyetsimBean.bilyet.deproduct.periodOpt)}" />

                                <h:outputLabel value= "#{bundle.numOfPeriod}" /><h:outputLabel value= ":" />
                                <h:outputText id="bilyetNumOfPeriod" styleClass="alignNum" value="#{bilyetsimBean.bilyet.deproduct.numOfPeriod}" />
                                    
                                <h:outputLabel value= "#{bundle.amount}" /><h:outputLabel value= ":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="99999999999999999999.99" minValue="0" 
                                        styleClass="money" value="#{bilyetsimBean.bilyet.principleAmount}" required="true"
                                        requiredMessage="#{bundle.amount} #{bundle.requiredInput}" label="#{bundle.amount}"
                                        id="bilyetPrincipalAmountsim" style="width: 200px;" disabled="#{!bilyetsimBean.authorized}">
                                        <p:ajax update="msgbilyetPrincipalAmountsim  bilyetInterestAmountsim bilyetTaxAmountsim" process="@this" 
                                                partialSubmit="false" listener="#{bilyetsimBean.calculateAmount()}"/>
                                    </pe:inputNumber>
                                    <p:message id="msgbilyetPrincipalAmountsim" for="bilyetPrincipalAmountsim" display="icon" />
                                </h:panelGrid> 
                                
                                <h:outputLabel value="#{bundle.interestRate}" /><h:outputLabel value= ":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999.99" minValue="0" symbol=" %" symbolPosition="s"
                                        styleClass="percent" value="#{bilyetsimBean.bilyet.interestRate}" label="#{bundle.interestRate}"
                                        requiredMessage="#{bundle.amount} #{bundle.requiredInput}"
                                        required="true" id="bilyetinterestRatesim" style="width: 50px;" disabled="#{!bilyetsimBean.authorized}">
                                        <p:ajax update="msgbilyetinterestRatesim bilyetInterestAmountsim bilyetTaxAmountsim" process="@this" 
                                                partialSubmit="false" listener="#{bilyetsimBean.calculateAmount()}"/>
                                    </pe:inputNumber>
                                    <p:message id="msgbilyetinterestRatesim" for="bilyetinterestRatesim" display="icon" />
                                </h:panelGrid>
                                
                                <h:outputLabel value= "#{bundle.interestAmount}" /><h:outputLabel value= ":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="99999999999999999999.99" minValue="0" 
                                        styleClass="money" value="#{bilyetsimBean.bilyet.interestAmount}" 
                                        requiredMessage="#{bundle.interestAmount} #{bundle.requiredInput}"
                                        required="true" label="#{bundle.interestAmount}" style="width: 200px;"
                                        id="bilyetInterestAmountsim" disabled="#{!bilyetsimBean.authorized}">
                                        <p:ajax update="msgbilyetInterestAmountsim" process="@this"/>
                                    </pe:inputNumber>
                                    <p:message id="msgbilyetInterestAmountsim" for="bilyetInterestAmountsim" display="icon" />
                                </h:panelGrid> 
                                
                                <h:outputLabel value= "#{bundle.taxAmount}" /><h:outputLabel value= ":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="99999999999999999999.99" minValue="0" 
                                        styleClass="money" value="#{bilyetsimBean.bilyet.taxAmount}" 
                                        requiredMessage="#{bundle.taxAmount} #{bundle.requiredInput}"
                                        required="true" label="#{bundle.taxAmount}" style="width: 200px;"
                                        id="bilyetTaxAmountsim" disabled="#{!bilyetsimBean.authorized}">
                                        <p:ajax update="msgbilyetTaxAmountsim" process="@this"/>
                                    </pe:inputNumber>
                                    <p:message id="msgbilyetTaxAmountsim" for="bilyetTaxAmountsim" display="icon" />
                                </h:panelGrid> 
                                
                            </h:panelGrid>
                        </p:panel>

                        <h:panelGrid columns="1" cellpadding="1" rowClasses="panelGridId" border="0" >
                             <p:panel header="SIMULASI DEPOSIT">
                                 <p:dataTable id="dtBilyetsim" value="#{bilyetsimBean.bilyets}" var="simulasi" rowIndexVar="noUrut">
                            
                                <p:column style="width: 12px;">
                                    <f:facet name="header">No</f:facet>
                                    <h:outputText value="#{noUrut+1}" />
                                </p:column>

                                <p:column style="width: 50px;">
                                    <f:facet name="header">#{bundle.date}</f:facet>
                                    <h:outputText value="#{simulasi.bilyetDate}" />
                                </p:column>

                                <p:column style="width: 90px;">
                                    <f:facet name="header">Bunga</f:facet>
                                    <h:outputText value="#{simulasi.interestAmount}" styleClass="numPos" >
                                        <f:convertNumber />
                                    </h:outputText>
                                </p:column>

                                <p:column style="width: 80px;">
                                    <f:facet name="header">Pajak</f:facet>
                                    <h:outputText value="#{simulasi.taxAmount}" styleClass="numPos" >
                                        <f:convertNumber />
                                    </h:outputText>
                                </p:column>
                                
                                <p:columnGroup type="footer">  
                                    <p:row>  
                                        <p:column colspan="2" style="text-align:right" footerText="Totals:"/> 
                                        <p:column style="text-align:right" footerText="#{bilyetsimBean.interestAmounts}" />    
                                        <p:column style="text-align:right" footerText="#{bilyetsimBean.taxAmounts}" />    
                                    </p:row>
                                </p:columnGroup>
                                 

                            </p:dataTable>
                        </p:panel>
                        </h:panelGrid>
                    </h:panelGrid>
                </h:panelGrid>
            
            </h:form>
        </ui:composition>    
    </h:body>
</html>